﻿@model List<BTKERP.Model.RequisitionMaster> 
@{
    ViewBag.Title = "MyReq";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

@section AdditionalJS
{
    <script type="text/javascript">
        function voidItem(mid) {
            if (confirm("Are you sure to void this requistion?"))
            {
                $.post("/Requistion/Void", {id : mid}, function(data){
                    if (data && data.Message.length > 0)
                     {   alert(data.Message);}
                    window.location.href = window.location.href; 
                });
            }
        }
    </script>
}

<h2>My Requisition</h2>

@if (Model == null || Model.Count == 0)
{
    <h1>There is no requisition</h1>
    <br />
    <h1>Click <a href="@Url.Action("Index", "Requistion")">Here</a> to add new requisition</h1>
}
else
{
    <table id="dt" class="display stylized">
        <tr>
            <th>
                Requisition Code
            </th>
            <th>
                Requisition By
            </th>
            <th>
                Requisition Date
            </th>
            <th>
                Delivery Date
            </th>
            <th></th>
        </tr>
        @foreach (var item in Model)
        {
            <tr>
                <td>
                    @item.RequisitionCode
                </td>
                <td>
                    @item.RequisitionedBy
                </td>
                <td>
                    @item.RequisitionDate.ToString("MM/dd/yyyy")
                </td>
                <td>
                    @item.DeliveryDate.Value.ToString("MM/dd/yyyy")
                </td>
                <td>
                    <a href="/Requistion/AddDetail/@item.Id.ToString()">Edit</a>
                    <a href="javascript:voidItem('@item.Id.ToString()');">Void</a>
                </td>
            </tr>
        }
        
    </table>

}
